import type { Route } from '@/types/template'

/**
 * 成人价格
 * @param route
 * @param adultNum
 * @returns
 */
export const computedAdultMoney = (route: Route | undefined, adultNum: number): number => {
  if (route == null) {
    return 0
  }
  return adultNum * route.adult_market_price
}

/**
 * 儿童价格
 * @param route
 * @param childNum
 * @returns
 */
export const computedChildMoney = (route: Route | undefined, childNum: number): number => {
  if (route == null) {
    return 0
  }
  return childNum * route.child_market_price
}

/**
 * 单房差价格
 * @param route
 * @param adultNum
 * @param childNum
 * @returns
 */
export const computedSinglePrice = (
  route: Route | undefined,
  adultNum: number,
  childNum: number,
): number => {
  if (route == null) {
    return 0
  }
  return (adultNum + childNum) % 2 == 1 ? route.single_price : 0
}
